<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>OOJ</title>
<script src="../js/jquery-1.8.0.min.js"></script>
		<script type="text/javascript">
			/*
			 *$(document).ready(function(){});
			 *$().ready(function(){}); //一般不用 
			 *$(function(){});
			 *
			 *这三种方式都可以
			 */
			$(function(){
			 	$("#btn").click(function(){
					/*清除type属性为text且索引值大于0的input标签*/ 
			 		//$("input[type=text]:gt(0)").remove();
			 		//$("#dynamic").html("");
			 		$("#dynamic").empty();
					var num = $("#num").val();
					for(var i=0;i<num;i++){
						var input = $("<input type=text>");/*这行必须定义在循环体内 ,在体外只会添加一个 */
						$("#dynamic").append(input);
						console.log(input);
					}
				});
			});
		</script>
	</head>
	<body>
		<br><a href="../index.jsp">back</a>
		<br><hr color="red" />
		<h5>jquery动态生成文本框</h5>
		<div>
			<input type="text" size=5 id="num" />
			<input type="button" id="btn" value="Go" />
		</div>
		<div id="dynamic" style="width:30%">
		</div>
	</body>
</html>